import java.util.ArrayList;

public class SelectionSort
{
    public static void main(String[] args)
    {
        ArrayList<Integer> myList = new ArrayList<Integer>(10);
        myList.add(10);
        myList.add(9);
        myList.add(8);
        myList.add(7);
        myList.add(6);
        myList.add(5);
        myList.add(4);
        myList.add(3);
        myList.add(2);
        myList.add(1);

        SelectionSort.printList(myList);
        SelectionSort.sort(myList);
        SelectionSort.printList(myList);
    }
    public static void sort(ArrayList<Integer> list)
    {
        for(int i = 0; i<list.size(); i++)
        {
            int currMin = list.get(i);
            int currIndex = i;
            for(int j = i; j< list.size(); j++)
            {
                if(list.get(j)<currMin)
                {
                    currMin = list.get(j);
                    currIndex = j;
                }
            }
            list.set(currIndex,list.get(i));
            list.set(i,currMin);
        }
    }

    public static void printList(ArrayList<Integer> list)
    {
        for(int i : list)
        {
            System.out.println(i);
        }
    }
}
